<html><body>
<h1>Macro Library stats</h1>
A library of Stats functions.  Version 1.8, June 20, 2007
<BR><ul>
<li><a href="#nCr">nCr</a></li>
<li><a href="#nPr">nPr</a></li>
<li><a href="#mean">mean</a></li>
<li><a href="#variance">variance</a></li>
<li><a href="#stdev">stdev</a></li>
<li><a href="#percentile">percentile</a></li>
<li><a href="#quartile">quartile</a></li>
<li><a href="#median">median</a></li>
<li><a href="#freqdist">freqdist</a></li>
<li><a href="#frequency">frequency</a></li>
<li><a href="#countif">countif</a></li>
<li><a href="#histogram">histogram</a></li>
<li><a href="#fdhistogram">fdhistogram</a></li>
<li><a href="#normrand">normrand</a></li>
<li><a href="#boxplot">boxplot</a></li>
<li><a href="#normalcdf">normalcdf</a></li>
<li><a href="#tcdf">tcdf</a></li>
<li><a href="#invnormalcdf">invnormalcdf</a></li>
<li><a href="#invtcdf">invtcdf</a></li>
<li><a href="#linreg">linreg</a></li>
<li><a href="#binomialpdf">binomialpdf</a></li>
<li><a href="#binomialcdf">binomialcdf</a></li>
<li><a href="#chi2cdf">chi2cdf</a></li>
<li><a href="#invchi2cdf">invchi2cdf</a></li>
<li><a href="#gamma_cdf">gamma_cdf</a></li>
<li><a href="#gamma_inc">gamma_inc</a></li>
<li><a href="#gamma_log">gamma_log</a></li>
<li><a href="#fcdf">fcdf</a></li>
<li><a href="#fcall">fcall</a></li>
<li><a href="#fspin">fspin</a></li>
<li><a href="#LJspin">LJspin</a></li>
<li><a href="#invfcdf">invfcdf</a></li>
</ul>
<h3><a name="nCr">nCr</a></h3>
nCr(n,r)
<BR>The Choose function
<BR><h3><a name="nPr">nPr</a></h3>
nPr(n,r)
<BR>The Permutations function
<BR><h3><a name="mean">mean</a></h3>
mean(array)
<BR>Finds the mean of an array of numbers
<BR><h3><a name="variance">variance</a></h3>
variance(array)
<BR>the (sample) variance of an array of numbers
<BR><h3><a name="stdev">stdev</a></h3>
stdev(array)
<BR>the (sample) standard deviation of an array of numbers
<BR><h3><a name="percentile">percentile</a></h3>
percentile(array,percentile)
<BR>example: percentile($a,30) would find the 30th percentile of the data
<BR>method based on Triola
<BR><h3><a name="quartile">quartile</a></h3>
quartile(array,quartile)
<BR>finds the 0 (min), 1st, 2nd (median), 3rd, or 4th (max) quartile of an
<BR>array of numbers.  Calculates using percentiles.
<BR><h3><a name="median">median</a></h3>
median(array)
<BR>returns the median of an array of numbers
<BR><h3><a name="freqdist">freqdist</a></h3>
freqdist(array,label,start,classwidth)
<BR>display macro.  Returns an HTML table that is a frequency distribution of
<BR>the data
<BR> array: array of data values
<BR> label: name of data values
<BR> start: first lower class limit
<BR> classwidth: width of the classes
<BR><h3><a name="frequency">frequency</a></h3>
frequency(array,start,classwidth)
<BR>Returns an array of frequencies for the data grouped into classes
<BR> array: array of data values
<BR> start: first lower class limit
<BR> classwidth: width of the classes
<BR><h3><a name="countif">countif</a></h3>
countif(array,condition)
<BR>Returns count of items in array that meet condition
<BR> array: array of data values
<BR> condition: a condition, using x for data values
<BR>Example: countif($a,"x<3 && x>2")
<BR><h3><a name="histogram">histogram</a></h3>
histogram(array,label,start,classwidth,[labelstart,upper])
<BR>display macro.  Creates a histogram from a data set
<BR> array: array of data values
<BR> label: name of data values
<BR> start: first lower class limit
<BR> classwidth: width of the classes
<BR> labelstart (optional): value to start axis labeling at.  Defaults to start
<BR> upper (optional): first upper class limit.  Defaults to start+classwidth
<BR><h3><a name="fdhistogram">fdhistogram</a></h3>
fdhistogram(freqarray,label,start,cw,[labelstart,upper])
<BR>display macro.  Creates a histogram from frequency array
<BR> freqarray: array of frequencies
<BR> label: name of data values
<BR> start: first lower class limit
<BR> classwidth: width of the classes
<BR> labelstart (optional): value to start axis labeling at.  Defaults to start
<BR> upper (optional): first upper class limit.  Defaults to start+classwidth
<BR><h3><a name="normrand">normrand</a></h3>
normrand(mu,sigma,n)
<BR>returns an array of n random numbers that are normally distributed with given
<BR>mean mu and standard deviation sigma.  Uses the Box-Muller transform.
<BR><h3><a name="boxplot">boxplot</a></h3>
boxplot(array,axislabel,[datalabel])
<BR>draws a boxplot based on the data in array, with given axislabel
<BR>and optionally a datalabel (to topleft of boxplot)
<BR>array and datalabel can also be an array of dataarrays and
<BR>array of datalabels to do comparative boxplots
<BR><h3><a name="normalcdf">normalcdf</a></h3>
normalcdf(z,[dec])
<BR>calculates the area under the standard normal distribution to the left of the
<BR>z-value z, to dec decimals (defaults to 4) 
<BR>based on someone else's code - can't remember whose!
<BR><h3><a name="tcdf">tcdf</a></h3>
tcdf(t,df,[dec])
<BR>calculates the area under the t-distribution with "df" degrees of freedom
<BR>to the left of the t-value t
<BR>based on someone else's code - can't remember whose!
<BR><h3><a name="invnormalcdf">invnormalcdf</a></h3>
invnormalcdf(p,[dec])
<BR>Inverse Normal CDF
<BR>finds the z-value with a left-tail area of p, to dec decimals (default 5)
<BR> from Odeh & Evans. 1974. AS 70. Applied Statistics. 23: 96-97
<BR><h3><a name="invtcdf">invtcdf</a></h3>
invtcdf(p,df,[dec])
<BR>the inverse Student's t-distribution 
<BR>computes the t-value with a left-tail probability of p, with df degrees of freedom
<BR>to dec decimal places (default 4)
<BR> from Algorithm 396: Student's t-quantiles by G.W. Hill  Comm. A.C.M., vol.13(10), 619-620, October 1970
<BR><h3><a name="linreg">linreg</a></h3>
linreg(xarray,yarray)
<BR>Computes the linear correlation coefficient, and slope and intercept of
<BR>regression line, based on array/list of x-values and array/list of y-values
<BR>Returns as array:  r,slope,intercept
<BR><h3><a name="binomialpdf">binomialpdf</a></h3>
binomialpdf(N,p,x)
<BR>Computes the probability of x successes out of N trials
<BR>where each trial has probability p of success
<BR><h3><a name="binomialcdf">binomialcdf</a></h3>
binomialcdf(N,p,x)
<BR>Computes the probably of &lt;=x successes out of N trials
<BR>where each trial has probability p of success
<BR><h3><a name="chi2cdf">chi2cdf</a></h3>
chi2cdf(x,df)
<BR>Computes the area to the left of x under the chi-squared disribution
<BR>with df degrees of freedom
<BR><h3><a name="invchi2cdf">invchi2cdf</a></h3>
invchi2cdf(p,df)
<BR>Compuates the x value with left-tail probability p under the 
<BR>chi-squared distribution with df degrees of freedom
<BR><h3><a name="gamma_cdf">gamma_cdf</a></h3>
<h3><a name="gamma_inc">gamma_inc</a></h3>
<h3><a name="gamma_log">gamma_log</a></h3>
<h3><a name="fcdf">fcdf</a></h3>
fcdf(f,df1,df2)
<BR>Returns the area to right of the F-value f for the f-distribution
<BR>with df1 and df2 degrees of freedom (techinically it's 1-CDF)
<BR>Algorithm is accurate to approximately 4-5 decimals
<BR><h3><a name="fcall">fcall</a></h3>
<h3><a name="fspin">fspin</a></h3>
<h3><a name="LJspin">LJspin</a></h3>
<h3><a name="invfcdf">invfcdf</a></h3>
invfcdf(p,df1,df2)
<BR>Computes the f-value with probability of p to the right
<BR>with degrees of freedom df1 and df2
<BR>Algorithm is accurate to approximately 2-4 decimal places
<BR>Less accurate for smaller p-values
<BR>